package org.mil.bean.bo;

import org.mil.bean.dom.VideoTrackDO;
import org.mil.util.MyMath;
import org.mil.util.TextUtil;

public class VideoTrack extends Track {

	// private String ID;
	private String format;
	// private String format_Info;
	private String format_profile;

	private int duration; // minutes
	private int nominal_bit_rate; // kbps
	private int width; // pixel
	private int height; // pixel
	private int display_aspect_ratio_w;
	private int display_aspect_ratio_h;
	private int frame_rate_x1k; // fps * 1000
	private String color_space;
	private byte bit_depth; // bits
	private int bits_per_pixelframe_x10k; // bits/(px*f) *1000
	private String title;
	private String writing_library;
	private H264ConfigInfo h264ConfigInfo;

	public void load(VideoTrackDO source) {

		format = source.getFormat();
		format_profile = source.getFormat_profile();
		//duration = TextUtil.getMinutes(source.getDuration());
		nominal_bit_rate = (int) TextUtil.quantify(
				source.getNominal_bit_rate(), "Kbps");
		width = (int) TextUtil.quantify(source.getWidth(), "pixels");
		height = (int) TextUtil.quantify(source.getHeight(), "pixels");

		String[] dar = source.getDisplay_aspect_ratio().split(":");
		int w, h;
		w = (int) (Double.valueOf(dar[0]) * 1000);
		if (dar.length < 2)
			h = 1000;
		else
			h = (int) (Double.valueOf(dar[1]) * 1000);

		display_aspect_ratio_w = MyMath.p_reduced(w, h);
		display_aspect_ratio_h = MyMath.q_reduced(w, h);
		frame_rate_x1k = (int) (TextUtil.quantify(source.getFrame_rate(), "fps") * 1000);
		color_space = source.getColor_space();
		bit_depth = (byte) TextUtil.quantify(source.getBit_depth(), "bits");		
		title = source.getTitle();
		bits_per_pixelframe_x10k=(int)( TextUtil.quantify(source.getBits__Pixel_Frame_())*10000);
		writing_library = source.getWriting_library();
		h264ConfigInfo = H264ConfigInfo.newInstance(source
				.getEncoding_settings());

	}

	// private String language;
	public String getFormat() {
		return format;
	}

	public void setFormat(String format) {
		this.format = format;
	}

	public String getFormat_profile() {
		return format_profile;
	}

	public void setFormat_profile(String formatProfile) {
		format_profile = formatProfile;
	}

	public int getDuration() {
		return duration;
	}

	public void setDuration(int duration) {
		this.duration = duration;
	}

	public int getNominal_bit_rate() {
		return nominal_bit_rate;
	}

	public void setNominal_bit_rate(int nominalBitRate) {
		nominal_bit_rate = nominalBitRate;
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}

	public int getDisplay_aspect_ratio_w() {
		return display_aspect_ratio_w;
	}

	public void setDisplay_aspect_ratio_w(int displayAspectRatioW) {
		display_aspect_ratio_w = displayAspectRatioW;
	}

	public int getDisplay_aspect_ratio_h() {
		return display_aspect_ratio_h;
	}

	public void setDisplay_aspect_ratio_h(int displayAspectRatioH) {
		display_aspect_ratio_h = displayAspectRatioH;
	}

	public int getFrame_rate_x1k() {
		return frame_rate_x1k;
	}

	public void setFrame_rate_x1k(int frameRateX1k) {
		frame_rate_x1k = frameRateX1k;
	}

	public String getColor_space() {
		return color_space;
	}

	public void setColor_space(String colorSpace) {
		color_space = colorSpace;
	}

	public byte getBit_depth() {
		return bit_depth;
	}

	public void setBit_depth(byte bitDepth) {
		bit_depth = bitDepth;
	}

	public int getBits_per_pixelframe_x10k() {
		return bits_per_pixelframe_x10k;
	}


	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getWriting_library() {
		return writing_library;
	}

	public void setWriting_library(String writingLibrary) {
		writing_library = writingLibrary;
	}

	public void setH264ConfigInfo(H264ConfigInfo h264ConfigInfo) {
		this.h264ConfigInfo = h264ConfigInfo;
	}

	public H264ConfigInfo getH264ConfigInfo() {
		return h264ConfigInfo;
	}

}
